<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@page import="net.groupme.gui.constants.VIEW_VOCABULARY"%>
<%@page import="net.groupme.model.Resource"%>
<%@page import="net.groupme.model.ObjectFactory"%>
<%@page import="net.groupme.utils.HTTPUtilities"%>
<div id="mainGroupwindowContent" style="margin-top:1em;">
<h4>Your Resource Queue</h4>
<% if(HTTPUtilities.getStringValue(request, VIEW_VOCABULARY.PARAMETER_ID) != null 
		&& HTTPUtilities.getStringValue(request, VIEW_VOCABULARY.PARAMETER_GROUP) != null){ //resource from queue was added to group(s)
	Resource resource = ObjectFactory.getResource(HTTPUtilities.getStringValue(request,VIEW_VOCABULARY.PARAMETER_ID));
%>
	<div class="messageBox" style="margin-top:1em;">Resource <i><a href="<%= resource.getURI() %>"><%= resource.getName() %></a></i> was successfully added to the following group(s):
	<% 	String groupList = "";
		String[] groups = request.getParameterValues(VIEW_VOCABULARY.PARAMETER_GROUP);
		for (int i = 0; i < groups.length; i++) {
			groupList += "<a href=\"" + VIEW_VOCABULARY.RESTful_GROUP_URI_PATTERN + groups[i] + "\" title=\"Visit group in order to arrange the resource!\">" + ObjectFactory.getGroup(groups[i]).getName() + "</a>" ;
			if(i+1 != groups.length){
				groupList += ", ";
			}
		}%>
		<%= groupList %> <br/>
	</div>
<% } else if(request.getParameter(VIEW_VOCABULARY.PARAMETER_ID) != null){ //resource from queue was removed
	Resource resource = ObjectFactory.getResource(request.getParameter(VIEW_VOCABULARY.PARAMETER_ID)); %>
	<div class="messageBox" style="margin-top:1em;">Resource <i><a href="<%= resource.getURI() %>"><%= resource.getName() %></a></i> was successfully removed from your queue.</div>
	<%}%>

<c:choose>
	<c:when test="${userManager.queueOfUserEmpty}">
	<p style="font-size:0.8em; margin-top:1em;"><i>At the moment your resource queue is empty :)</i></p>
	</c:when>
	<c:otherwise>
		<c:forEach items="${userManager.resourcesOfQueue}" var="resource">
			<div class="groupWithinGroupList" style="font-size:0.8em;">
				<strong><a href="<%= VIEW_VOCABULARY.RESTful_MyGroupMe_MOVE_RESOURCE %><c:out value="${resource.id}"/>" title="add to group(s)..."><c:out value="${resource.name}"/></a></strong><br/>
				<c:choose>
					<c:when test="${resource.type == 'image'}">
						<img src="<c:out value='${resource.URL}'/>" alt="" width="200px"/> <br/>
					</c:when>
					<c:when test="${resource.type == 'shockwave'}">
					<object>
						<param name="movie" value="<c:out value='${resource.URL}'/>"></param>
						<param name="wmode" value="transparent"></param>
						<embed id="<c:out value='${resource.name}'/>_contentVideo" src="<c:out value='${resource.URL}'/>"
							type="application/x-shockwave-flash" wmode="transparent">
						</embed>
					</object> <br/>
					</c:when>
					<c:otherwise>
					</c:otherwise>
				</c:choose>
				<c:out value="${resource.description}"/><br/>
				<small>
					<a href="<%= VIEW_VOCABULARY.RESTful_MyGroupMe_MOVE_RESOURCE %><c:out value="${resource.id}"/>" title="add to group(s)...">add to group(s)</a> 
					| <a href="<%= VIEW_VOCABULARY.GROUPME_BASE_URL +  VIEW_VOCABULARY.ACTION_REMOVE_RESOURCE_FROM_QUEUE + "?" + VIEW_VOCABULARY.PARAMETER_ID + "=" %><c:out value='${resource.id}'/>" title="Delete from Resource Queue!">delete</a>
				</small>
				<hr/>
			</div>
		</c:forEach>
	</c:otherwise>
</c:choose>
		
</div>